﻿/*
作者：魏铁雷
时间：209-11-25
功能：新闻列表显示
**/
var User_Account = "";
var ModelId = "";
var PageSize = 18;
var ArrList = new Array();
var page = 1;
var key = "";
var drops = "0";
var ModelParentId;
var cou = 0; //记录条数
var ModelName = "";

function ShowMain() {
    page = request("page")
    if (page == undefined||page=="") {
        page = 1;
        GetNewsList(1, key,drops);
    }
    else {
        page = request("page");
        GetNewsList(page, key,drops);
    }

}

function SelectAll(id, name)//全选
{
    var checks = document.getElementsByTagName("input");
    for (var i = 0; i < checks.length; i++) {
        if (checks[i].name == name) {
            checks[i].checked = document.getElementById(id).checked;
        }
    }
};

function SelectIDs(name) {
    var checks = document.getElementsByTagName("input");
    var str = "";
    for (var i = 0; i < checks.length; i++) {
        if (checks[i].name == name && checks[i].checked) {
            str += checks[i].value + ",";
        }
    }
    return str;
};

//获取"信息列表"
function GetNewsList(pg, key, dropdown) {
    ModelId = request("ModelId");
    ModelParentId = request("ModelParentId");
    ModelName = request("name");
    if (key == undefined) {
        key = "";
    }
    indexpage = pg;
    page = pg;
    drops = dropdown;
    var url = encodeURI(SBasePath + '/action/Contents/NewsList.aspx');
    var pars = encodeURI("?PageIndex=" + pg + "&PageSize=" + PageSize + "&modelid=" + ModelId + "&key=" + key+"&drop="+dropdown);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetNewsList, onFailure: fGetNewsList });

}
//获取"栏目列表"成功
function sGetNewsList(o) {
    var se = o.responseText;
    if (se == "SessionError") {
        alert('当前会话已失效，请重新登录!');
        window.top.location.href = SBasePath + '/Login.htm';
    }

    ArrList = MapNewsList(o);
    Total = MapPage(o, "RecordCount");
    User_Account = MapPage(o, "username");
    cou = Total;
    PageIndex = MapPage(o, "PageIndex");
    PageTotal = Math.ceil(Total / PageSize)
    ShowContent();

    }

function fGetNewsList(o) {

}

//function OpenWin(i) {
//    var url = WebBasePath+ArrList[i].HtmUrl;
//    window.open(url, "", "");
//}
//显示列表
function ShowContent() {
    var str = "";
    str += '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">';
    str += '        <tr>';
    str += '            <td height="30">';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                    <tr>';
    str += '                        <td width="15" height="30">';
    str += '                            <img src="../../img/tab_03.gif" width="15" height="30" />';
    str += '                        </td>';
    str += '                        <td width="1101" background="../../img/tab_05.gif">';
    str += '                            <img src="../../img/311.gif" width="16" height="16" />';
    str += '                            <span class="title1">信息列表</span>';
    str += '                        </td>';
    str += '                        <td width="281" background="../../img/tab_05.gif">';
    str += '                            <table border="0" align="right" cellpadding="0" cellspacing="0">';

    str += '                                <tr>';
    
    //2011-3-18新加
    str += '                                    <td width="60">';
    str += '                                        <table width="87%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td style="position:relative;cursor:hand" class="mail35" onmouseover="this.className=\'mail351\'" onmouseout="this.className=\'mail35\'">';
    str += '<img src="../../images/e-mail_35.gif" onclick="GetModel()" />';
    str += '<div style="display:none;position:absolute; left:0;top:25px; text-align:left; padding:0px;  color:#dc6800;overFlow-x: hidden;overFlow-y: auto ; width:200px;height:480px; " id="content_xiedx"></div>'; 
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    
    str += '                                    <td width="60">';
    str += '                                        <table width="87%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    str += '                                                        <input id="ChkAll" type="checkbox" onclick=\'SelectAll("ChkAll","ChkAllValue")\' />';
    str += '                                                </td>';
    str += '                                                <td>';
    str += '                                                    <div align="center" class="f_green">全选</div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                    <td width="60">';
    str += '                                        <table width="90%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    str += '                                                        <img src="../../img/001.gif" width="14" height="14" /></div>';
    str += '                                                </td>';
    str += '                                                <td>';
    str += '                                                    <div align="center" class="f_green"><a style="cursor: hand" onclick="javascript:NewsAdd()">新增</a></div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                    <td width="52">';
    str += '                                        <table width="88%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    str += '                                                        <img src="../../img/083.gif" width="14" height="14" /></div>';
    str += '                                                </td>';
    str += '                                                <td>';
    str += '                                                    <div align="center" class="f_green"><a style="cursor: hand" onclick="javascript:DelNews(\'ChkAllValue\')">删除</a></div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                </tr>';
    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="14">';
    str += '                            <img src="../../img/tab_07.gif" width="14" height="30" />';
    str += '                        </td>';
    str += '                    </tr>';
    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';


    //***********************************查询
    str += '<form id="newlist">';
    str += '<tr>';
    str += '    <td valign="top" ><table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '<tr>';
    str += '        <td width="9" class="tab12"></td>';
    str += '<td bgcolor="#f3ffe3" ><table border="0" cellpadding="0" cellspacing="0" ';
    str += 'width="99%" class="k_green" align="center">';
    str += '        <tr>';
    str += '          <td width="90" align="center"  height="25"  class="f_green" >搜索条件：</td>';
    str += '          <td width="132">';
    str += '          <select name="cid" style="width:120px">';
    str += '          <option value="0"  class="f_green">选择类型</option>';
    str += '          <option value="1" class="f_green" >文章标题</option>';
    str += '		  <option value="2"  class="f_green">作者</option>';
    str += '          </select>';
    str += '        </td>';
    str += '        <td width="56"  class="f_green">';
    str += '          关键字：        </td>';
    str += '        <td width="180">';
    str += '          	<input type="text" name="keyword" value=""  class="f_green"  />';
    str += '        </td>';
    str += '        <td><input type="button" name="Submit" onclick="search(keyword.value,cid.options[cid.selectedIndex].value);" value="查询" class="bg_w"';
    str += 'style="border:height:22px;width:55px; border:solid 1px #cadcb2;"/>';
    str += '        </td>';
    str += '       </tr>';
    str += '      </table></td>';
    str += '        <td width="8" class="tab16"></td>';
    str += '      </tr>';
    str += '    </table></td>';
    str += '  </tr>';
    str += '</form>';
    //*************************************************
    
    
    
    str += '        <tr>';
    str += '            <td>';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';

    str += '                    <tr>';
    str += '                        <td width="9" background="../../img/tab_12.gif"> &nbsp;</td>';
    str += '                        <td bgcolor="#f3ffe3">';
    str += '                            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98">';
    str += '                                <tr>';
    str += '                                    <td width="5%" height="26" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">选择</div> ';
    str += '                                    </td>';
    str += '                                    <td width="5%" height="18" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">序号</div>';
    str += '                                    </td>';
    str += '                                    <td width="38%" height="18" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">标题</div>';
    str += '                                    </td>';
    str += '                                    <td width="10%" height="18" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">发布人</div>';
    str += '                                    </td>';
    str += '                                    <td width="10%" height="18" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">发布时间</div>';
    str += '                                    </td>';
//    str += '                                    <td width="6%" height="18" background="../../img/tab_14.gif">';
//    str += '                                        <div align="center" class="f_green">点击量</div>';
//    str += '                                    </td>'
    str += '                                    <td width="8%" height="18" background="../../img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green">审核状态</div>';
    str += '                                    </td>';
//    str += '                                    <td width="8%" height="18" background="../../img/tab_14.gif">';
//    str += '                                        <div align="center" class="f_green">审核设置</div>';
//    str += '                                    </td>';
    if (User_Account == "admin") {
        str += '                                    <td width="8%" height="18" background="../../img/tab_14.gif">';
        str += '                                        <div align="center" class="f_green">排序设置</div>';
        str += '                                    </td>';
        str += '                                    <td width="6%" height="18" background="../../img/tab_14.gif" >';
        str += '                                        <div align="center" class="f_green">头条</div>';
        str += '                                    </td>';
    }
    str += '                                    <td width="6%" height="18" background="../../img/tab_14.gif" >';
    str += '                                        <div align="center" class="f_green">编辑</div>';
    str += '                                    </td>';
    str += '                                    <td width="6%" height="18" background="../../img/tab_14.gif" >';
    str += '                                        <div align="center" class="f_green">删除</div>';
    str += '                                    </td>';
    str += '                                </tr>';
    for (var i = 0; i < ArrList.length; i++) {
        str += '                                <tr class="bg_w" onmouseout="this.className=\'bg_w\'" onmouseover="this.className=\'bg_g\'">';
        str += '                                    <td height="18">';
        str += '                                        <div align="center">';
        str += '                                            <input name="ChkAllValue" type="checkbox" value="' + ArrList[i].ID + '" />';
        str += '                                        </div>';
        str += '                                    </td>';
        str += '                                    <td height="18">';
        str += '                                        <div align="center" class="content">' + ArrList[i].DisPlayOrder + '</div>';
        //str += '                                        <div align="center" class="content">' + (PageSize * (PageIndex-1) +i+ 1) + '</div>';
        str += '                                    </td>';
        str += '                                    <td height="18" class="style1">';
        var bt = ArrList[i].Title;
        bt=CutChar(bt);
        if (bt.length > 24) {
            var t = (bt);//.slice(0, 24);
            str += '                                 <div align="left" class="content"><a style="cursor: hand" title="' + bt + '" onclick="javascript:OpenWin(\'' + i + '\')">' + t + '</a></div>';
        } else {
        str += '                                        <div align="left" class="content"><a style="cursor: hand" title="' + bt + '" onclick="javascript:OpenWin(\'' + i + '\')">' + bt + '</a></div>';
        }
        str += '                                    </td>';
        str += '                                    <td height="18">';
        str += '                                        <div align="center" class="content"> ' + ArrList[i].Account + '</div>';
        str += '                                    </td>'; 
        str += '                                    <td height="18">';
        str += '                                        <div align="center" class="content"> ' + ArrList[i].SendTime.slice(0, 10) + '</div>';
        str += '                                    </td>';
//        str += '                                    <td height="18">';
//        str += '                                        <div align="center" class="content">';
//        str += '                                            ' + ArrList[i].Hit + '</div>';
//        str += '                                    </td>';

        if (ArrList[i].ShenHe == "1") {
            str += '                                    <td height="18">';
            str += '                                        <div align="center" class="content">通过 【<a style="cursor: hand" onclick="javascript:ShenHe(\'' + ArrList[i].ID + '\',\'' + ArrList[i].ShenHe + '\')">设置</a>】</div>';
            str += '                                    </td>';
        } else {
        str += '                                    <td height="18">';
        str += '                                        <div align="center" class="content">未通过 【<a style="cursor: hand" onclick="javascript:ShenHe(\'' + ArrList[i].ID + '\',\'' + ArrList[i].ShenHe + '\')">设置</a>】</div>';
        str += '                                    </td>';
        }
//            str += '                                    <td height="18">';
//            str += '                                        <div align="center" class="content">';
//            str += '                                            <a style="cursor: hand" onclick="javascript:ShenHe(\'' + ArrList[i].ID + '\',\''+ArrList[i].ShenHe+'\')">设置</a></div>';
//            str += '                                    </td>';
            if (User_Account == "admin") {

                str += '<td height="18">';
                str += '<div align="center" class="content">';
                str += '<a style="cursor: hand" onclick="javascript:Show_xinxi(\'' + ArrList[i].ID + '\',\'' + ArrList[i].ModelID + '\',\'' + ArrList[i].DisPlayOrder + '\')">排序</a></div>';
                str += '</td>';

                str += '<td height="18">';
                str += '<div align="center" class="content">';
                if (ArrList[i].TopLeading == "1") {
                    str += '<font color="red">[头条]</font>'; //<a style="cursor: hand" onclick="javascript:Show_Cancel(\'' + ArrList[i].ID + '\')"></a>
                } else {
                    str += '                                       [<a style="cursor: hand" onclick="javascript:Show_SetTop(\'' + ArrList[i].ID + '\')">设置</a>]';
                }
                str += '</div>';
                str += '</td>';
            }
        str += '                                    <td height="18">';
        str += '                                        <div align="center">';
        str += '                                            <span>';
        str += '                                                <img src="../../img/037.gif" width="9" height="9" /></span><span> [</span><a href="javascript:EditModel(\'' + ArrList[i].ID + '\')" >编辑</a><span>]</span></div>';
        str += '                                    </td>';
        str += '                                    <td height="18">';
        str += '                                        <div align="center">';
        str += '                                            <span>';
        str += '                                                <img src="../../img/010.gif" width="9" height="9" /></span><span> [</span><a href="javascript:DelNews(\'' + ArrList[i].ID + '\')">删除</a><span>]</span></div>';
        str += '                                    </td>';
        str += '                                </tr>';
    }
    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="9" background="../../img/tab_16.gif">&nbsp;</td>';
    str += '                    </tr>';
    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';

    str += '        <tr>';
    str += '            <td height="29">';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                    <tr>';
    str += '                        <td width="15" height="29">';
    str += '                            <img src="../../img/tab_20.gif" width="15" height="29" />';
    str += '                        </td>';
    str += '                        <td background="../../img/tab_21.gif">';
    str += '                            <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                                <tr>';
    str += '                                    <td width="25%" height="29" nowrap="nowrap">';
    str += '                                        <span class="f_green">共' + Total + '条记录, 当前第' + PageIndex + '/' + PageTotal + '页,每页' + PageSize + '条纪录</span>';
    str += '                                    </td>';
    str += '                                    <td width="75%" valign="top">';
    str += '                                        <div align="right">';
    if (PageTotal > 1) {
        
        str += '                                            <table width="352" height="20" border="0" cellpadding="0" cellspacing="0">';
        str += '                                                <tr>';
        str += '                                                    <td width="62" height="22" valign="middle">';
        str += '                                                        <div align="right">';
        str += '                                                          <a href="javascript:void(0)" onclick="FirstPage(\'GetNewsList\')"><img src="../../img/first.gif" border="0" width="37" height="15" /></a></div>';
        str += '                                                    </td>';
        str += '                                                    <td width="50" height="22" valign="middle">';
        str += '                                                        <div align="right">';
        str += '                                                            <a href="javascript:void(0)" onclick="BackPage(\'GetNewsList\')"><img src="../../img/back.gif" border="0" width="43" height="15" /></a></div>';
        str += '                                                    </td>';
        str += '                                                    <td width="54" height="22" valign="middle">';
        str += '                                                        <div align="right">';
        str += '                                                            <a href="javascript:void(0)" onclick="NextPage(\'GetNewsList\')"><img src="../../img/next.gif" border="0" width="43" height="15" /></a></div>';
        str += '                                                    </td>';
        str += '                                                    <td width="49" height="22" valign="middle">';
        str += '                                                        <div align="right">';
        str += '                                                            <a href="javascript:void(0)" onclick="LastPage(\'GetNewsList\')"><img src="../../img/last.gif" border="0" width="37" height="15" /></a></div>';
        str += '                                                    </td>';
        str += '                                                    <td width="59" height="22" valign="middle">';
        str += '                                                        <div align="right">';
        str += '                                                            转到第</div>';
        str += '                                                    </td>';
        str += '                                                    <td width="25" height="22" valign="middle">';
        str += '                                                        <input name="page" type="text" style="height: 12px; width: 25px;" size="5" />';
        str += '                                                    </td>';
        str += '                                                    <td width="23" height="22" valign="middle">页</td>';
        str += '                                                    <td width="30" height="22" valign="middle">';
        str += '                                                        <a href="javascript:void(0)" onclick="GetNewsListPage()"><img src="../../img/go.gif" width="37" border="0" height="15" /></a>';
        str += '                                                    </td>';
        str += '                                                </tr>';
        str += '                                             </table>';
    }
    str += '                                        </div>';
    str += '                                    </td>';
    str += '                                </tr>';
    
    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="14">';
    str += '                            <img src="../../img/tab_22.gif" width="14" height="29" />';
    str += '                        </td>';
    str += '                    </tr>';
    
    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';
    str += '    </table>';
    //显示弹出框
    str += '<div style="width: 100%; background-color:Gray; display:none; height: 100%; position:absolute;  left: 0; top: 0;" id="show1"></div><div style="width: 301px; display:none; height: 143px; position:absolute;  left: 200px; top: 127px;" id="content1"></div>';
    $("NewsList").innerHTML = str;
}
//标题去除html标记
function CutChar(titles) {
    var tmp = "";
    var tmp1 = "";
    tmp = titles.replace(/<(\w+)\s[^>]*>/g, "<$1>");
    tmp1 = tmp.replace(/<[^>]*>/g, '');
    return tmp1;
}
function OpenWin(i) {
    var url = "";
    var booltorf = checkeURL(ArrList[i].HtmUrl);

    if (booltorf == true) {
        url = ArrList[i].HtmUrl;
    }
    else {
        url = WebBasePath + ArrList[i].HtmUrl;
    }
    window.open(url, "", "");
}
//检索函数
function search(key,drop) {
    if (CheckAddForm()) {
        GetNewsList(page, key,drop);
    }
}

//显示排序框
function Show_xinxi(id,modlid,orid) {
    var str1 = "";
    str1 += '<input type="hidden" id="idstr" name="idstr" value="' + id + '"/>';
    str1 += '<input type="hidden" id="midstr" name="midstr" value="' + modlid + '"/>';
    str1 += '<input type="hidden" id="orids" name="orids" value="' + orid + '"/>';
            str1 += '<table border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc" id="move" style="position:absolute;" width="100%" height="70%">';
            str1 += '<tr bgcolor="#f3ffe3" style="cursor:move;" onmousedown="selectBegin(this);" onmousemove="selectMove(this);" onmouseup="selectEnd(this);"><td colspan="2" align="center" ><b>排序</b></td></tr>';
            str1 += '<tr bgcolor="#f3ffe3"><td width="30%" align="center" class="">移动到第</td>';
            str1 += '<td width="70%" class="" align="center">';
            str1 += '<input id="num" type="text" name="num" style="width:135px;" value="" />';
            str1 += '</td></tr>';
            str1 += '<tr bgcolor="#f3ffe3"><td width="30%" align="center" class="">方向</td>';
            str1 += '<td width="70%" class="" align="center">';
            str1 += '<input id="xq" type="radio" name="fx"  checked=true/>之前<input id="xh" name="fx" type="radio"  />之后';
            str1 += '</td></tr>';
            str1 += '<tr bgcolor="#f3ffe3"><td width="100%" colspan="2" align="center" class="">';
            str1 += '<input type="button" class="" onclick="PaiXu(num.value,idstr.value,midstr.value,orids.value,xq.checked)" value="保存"/>&nbsp;&nbsp;<input onclick="back()" type="button" class="" value="取消"/>';
            str1 += '</td></tr></table>';
            $("show1").style.display = "block";
            $("show1").style.filter = "Alpha(Opacity=10)";
            $("content1").style.display = "block";
            $("content1").innerHTML = str1;
}
//隐藏弹出框
function back() {
    $("show1").style.display = "none";
    $("content1").style.display = "none";    
    $("content1").innerHTML = "";
}
///----------------------------------------------------------div拖拽事件-----------------------------------------------------onmousedown="selectBegin(this);" onmousemove="selectMove(this);" onmouseup="selectEnd(this);" 
var theFlag = 0; //操作是否开始(1是；0否)
var theDiv; //拖曳对象
var x = 0; //鼠标按下时的初始x座标
var y = 0; //鼠标按下时的初始y座标
var divTop = 0; //拖曳对象当前的top值
var divLeft = 0; //拖曳对象当前的left值

//鼠标按下事件
function selectBegin(e) {
    theFlag = 1;
    e.setCapture();

    theDiv = document.getElementById("move");
    //鼠标起始值
    x = parseInt(document.body.scrollLeft) + parseInt(event.clientX); //鼠标按下初始x座标值
    y = parseInt(document.body.scrollTop) + parseInt(event.clientY); //鼠标按下初始y座标值
    divTop = parseInt(theDiv.offsetTop); //拖曳对象当前的top值
    divLeft = parseInt(theDiv.offsetLeft); //拖曳对象当前的left值
}
//鼠标移动事件
function selectMove(e) {
    if (theFlag == 1) {
        var mouseX = parseInt(document.body.scrollLeft) + parseInt(event.clientX); //捕获鼠标当前座标
        var mouseY = parseInt(document.body.scrollTop) + parseInt(event.clientY);
        theDiv.style.top = divTop + (mouseY - y); //重置拖曳对象位置
        theDiv.style.left = divLeft + (mouseX - x);
    }
}
//鼠标松开事件
function selectEnd(e) {
    theFlag = 0;
    e.releaseCapture();
}
//-------------------------------------------------------------------------------------------------
//排序设置
var bool;
var flg = "1";//1是向前0是向后
function PaiXu(num, id, mid, orids, bool) {
    if (num=="") {
        MsgDlg("请输入序号");
        return;
    }
    if (isNaN(num)) {
        MsgDlg("请输入数字");
        return;
    }
    if (parseInt(num) > parseInt(cou)) {
        MsgDlg("输入的数字超出范围");
        return;
    }
    if (bool == false)
    {flg = "0";}
    var url = encodeURI(SBasePath + '/action/Contents/PaiXu.aspx');
    var pars = encodeURI("?id=" + id + "&num=" + num+"&modid="+mid+"&orderid="+orids+"&fx="+flg);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetPaiXu, onFailure: fGetPaiXu });

}
function sGetPaiXu(o) {
    var root = o.responseXML.documentElement;
    var flag = GetXmlData(root, "Value");
    page = GetXmlData(root, "Page");
    if (flag == "true") {
        GetNewsList(indexpage,key,drops);
        //window.top.frames["Content"].location.href = SBasePath + '/htm/Contents/NewsList.htm?page=' + page + '&modelid=' + ModelId + '&key=' + key;
    }
    else {
        MsgDlg(GetMsg("0"));
    }

}
function fGetPaiXu(o) {
}


//新增、编辑特殊模块
//公园广场所以子模块、公开电话模块、古树名木模块
//增加新闻
function NewsAdd() {
//    if (ModelParentId == "20091125020428" || ModelId == "20100525103049" || ModelId == "20091214021843") {
//        location.href = SBasePath + "/htm/Contents/RelContent_GY.htm?ModelId=" + ModelId + "&ModelParentId=" + ModelParentId;
//    }
//    else {
        location.href = SBasePath + "/htm/Contents/RelContent.htm?ModelId=" + ModelId + "&ModelParentId=" + ModelParentId;
//    }
}
//修改
function EditModel(id) {
    if (ModelParentId == "20091125020428" || ModelId == "20100525103049" || ModelId == "20091214021843") {
        window.location.href = SBasePath + '/htm/Contents/UpdateContent_gy.htm?id=' + id;
    } else {
        window.location.href = SBasePath + '/htm/Contents/UpdateContent.htm?id=' + id;
    }
}

//----------------------修改审核状态--------------------------------//
function ShenHe(id, key) {
    if (ConfrimDlg(GetMsg("12"),"aa('"+id+"','"+ key+"')")) {        
    }
}
function aa(id, key)
{
var url = encodeURI(SBasePath + '/action/Contents/ShenHe.aspx');
        var pars = encodeURI("?idstr=" + id + "&key=" + key + "&page=" + indexpage);
        var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetShenHeList, onFailure: fGetShenHeList });
}
//获取"信息列表"成功
function sGetShenHeList(o) {

    var root = o.responseXML.documentElement;
    var flag = GetXmlData(root, "Value");
    page = GetXmlData(root, "Page");
    if (flag == "true") {
        GetNewsList(indexpage, key, drops);
        //window.top.frames["Content"].location.href = SBasePath + '/htm/Contents/NewsList.htm?page=' + page + '&modelid=' + ModelId + '&key=' + key;
    }
    else {
        MsgDlg(GetMsg("0"));
    }

}
function fGetShenHeList(o) {

}
//--------------------修改审核状态-------------------------------//
//修改新闻
function EditNew(id, pid) {
   // location.href = SBasePath + "/htm/ModelManage/ModelEdit.htm?modelid=" + id + "&page=" + indexpage + "&ModelPid=" + pid;
}
//---------------------------确认删除------------------------------------------------//
function DelNews(Id) {
    if (Id == "ChkAllValue") {
        var idstr = SelectIDs(Id);
        if (idstr.length == 0) {
            MsgDlg(GetMsg("10"));
        }
        else {
            ConfrimDlg(GetMsg("2"), "DelNew('" + idstr + "')");
        }
    } else {
    ConfrimDlg(GetMsg("2"), "DelNew('" + Id + "')");
    }
}

var DelNew = function(Id)//删除
{

    var url = encodeURI(SBasePath + '/action/Contents/DelNews.aspx');
    var pars = encodeURI('?idstr=' + Id+"&page=" + indexpage);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sDelNews, onFailure: fDelNews });

};

//操作成功
function sDelNews(o) {
    var root = o.responseXML.documentElement;
    var flag = GetXmlData(root, "Value");
    page = GetXmlData(root, "Page");
    if (flag == "true") {
        GetNewsList(indexpage, key, drops);
        //window.top.frames["Content"].location.href = SBasePath + '/htm/Contents/NewsList.htm?page=' + page + '&modelid=' + ModelId + '&key=' + key;
    }
    else {
        MsgDlg(GetMsg("0"));
    }
}

//操作失败
function fDelNews(o) {
}
//---------------------------确认删除------------------------------------------------//

function GetNewsListPage() {
    if (checkPage()) {
        if (key == undefined) {
            key = "";
        }
        var url = encodeURI(SBasePath + '/action/Contents/NewsList.aspx');
        var pars = encodeURI("?PageIndex=" + document.getElementById("page").value + "&PageSize=" + PageSize + "&modelid=" + ModelId+"&key="+key+"&drop="+drops);
        var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetNewsListPage, onFailure: fGetNewsListPage });
    }
}

function sGetNewsListPage(o) {
    ArrList = MapNewsList(o);
    Total = MapPage(o, "RecordCount");
    PageIndex = MapPage(o, "PageIndex");
    PageTotal = Math.ceil(Total / PageSize)
    if (document.getElementById("page").value > PageTotal) {
        MsgDlg('不能超出范围页数！');
        document.getElementById("page").value = "";
        return false;
    }
    ShowContent();
}

function fGetNewsListPage() {

}

var checkPage = function() {
    var page = document.getElementById("page").value;
    if (isNaN(page) || page == "") {
        MsgDlg('请输入页数！');
        return false;
    }
    return true;
}


var CheckAddForm = function() {

    var fobj = $("newlist");

    if (fobj.cid.options[fobj.cid.selectedIndex].value == "0") {
        //0所有类型
        MsgDlg("请选择检索类型");
        fobj.cid.focus();
        return false;
    }
    return true;
};
//设置头条
function Show_SetTop(ID) {
    if (ID != "") {
        ConfrimDlg("是否要将此文章设为头条", "SetTop('" + ID + "')");
    }
}

var SetTop = function(ID) {
    var url = encodeURI(SBasePath + '/action/Contents/UpdateTop.aspx');
    var pars = encodeURI("?SetID=" + ID);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetNewsSetTop, onFailure: fGetNewsSetTop });
}

function sGetNewsSetTop(o) {

    var root = o.responseXML.documentElement;
    var Value = GetXmlData(root, "Value");

    if (Value == "True") {
        MsgDlg("设置成功！");
        GetNewsList(page, key, drops);
    }
}

function fGetNewsSetTop() {

}



//2011-3-18新加xie
function GetModel() {
    if ($("content_xiedx").style.display == "block") { $("content_xiedx").style.display = "none"; return false; }
    
    var url = encodeURI(SBasePath + '/action/Contents/SelContentModel.aspx');
    var pars = encodeURI("");
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetModel, onFailure: fGetModel });
}
function sGetModel(o) {
    ArrListSendModel = MapSendModel(o);
    ModelShow();
}
function fGetModel() {
}
function ModelShow() {
    var str = '';
    str += '<table width="200px" bgcolor="#ffffff" id="tb" border="0" align="center" cellpadding="0" cellspacing="0" style="float:left; border-top:1px solid #aaaaaa;border-left:1px solid #aaaaaa;border-right:1px solid #aaaaaa;border-bottom:1px solid #aaaaaa;" >';
    for (var i = 0; i < ArrListSendModel.length; i++) {
        if (ArrListSendModel[i].ModelValue != "") {
            str += '<tr onmouseover="this.style.backgroundColor=\'#eafcd5\'" onmouseout="this.style.backgroundColor=\'#ffffff\'" onclick="select_item(\'' + ArrListSendModel[i].ModelValue + '\',\'' + ArrListSendModel[i].ModelName + '\')">';
            str += '<td height="20" style="cursor:hand" id="otd">';
        } else {
            str += '<tr>';
            str += '<td height="20" id="otd">';
        }
        str += '&nbsp;&nbsp;' + ArrListSendModel[i].ModelName;
        str += '</td>';
        str += '</tr>';
    }
    str += '</table>';    
    $("content_xiedx").style.display = "block";
    $("content_xiedx").innerHTML = str;
}
function select_item(MValue,MName) {
    var idstr = SelectIDs("ChkAllValue");
    if (idstr.length == 0) {
        alert("您还没有选择要移动的记录！"); $("content_xiedx").style.display = "none"; return false;
    }
    else {
        if (MValue == ModelParentId + "_" + ModelId) {
            alert("请选择其他模块！"); return false;
        }
        ConfrimDlg("您确定将选中信息移动到\"" + MName.replace("_", "") + "\"模块下吗？", "MesMoveTo('" + idstr + "','" + MValue + "')");
    }
}
function MesMoveTo(ids,MoValue) {
    GetNewsList(page, key, drops);
}

function MesMoveTo(ids, MoValue) {
    var url = encodeURI(SBasePath + '/action/Contents/SelContentMoveTo.aspx');
    var pars = encodeURI("?ids=" + ids + "&MoValue=" + MoValue);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sMesMoveTo, onFailure: fMesMoveTo });
}
function sMesMoveTo(o) {
    GetNewsList(1, key, drops);
}
function fMesMoveTo() {
}
//end

//2011-03-19点击别处隐藏列表
document.onclick = function(e) {
    e = e || window.event;
    var dom = e.srcElement || e.target;
    if (dom.id != "otd" && document.getElementById("content_xiedx").style.display == "block") {
        document.getElementById("content_xiedx").style.display = "none";
    }
}
//end
